# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Tuan Hoang <tmhoang@linux.ibm.com>
pkgname=s390-tools
pkgver=2.21.0
pkgrel=0
pkgdesc="Tools for use with the s390 Linux kernel and device drivers"
url="https://github.com/ibm-s390-tools/s390-tools"
arch="s390x"
license="MIT"
options="!check" # No test suite
depends="bash"
makedepends="linux-headers libexecinfo-dev zlib-dev fuse3-dev ncurses-dev openssl1.1-compat-dev libxml2-dev
	cryptsetup-dev json-c-dev net-snmp-dev curl-dev"
triggers="$pkgname.trigger=/boot"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ibm-s390-tools/s390-tools/archive/v$pkgver.tar.gz
	0002-musl-fixes.patch
	0004-missing-time-header.patch
	0006-define-path-mounted.patch
	0007-tunedasd-no-need-error-h.patch
	0008-iucvterm-no-nls.patch
	0009-link-libexecinfo.patch
	0010-musl-s390x-signal-def.patch

	0200-dasdinfo-gnu-ext-hack.patch
	0300-disable-program-using-gnu-ext.patch
	0400-busybox-compat.patch
	0500-remove-lib64.patch
	bash.patch
	argz.patch
	iucvterm-gettext.patch

	argz.c
	argz.h
	Makefile.argz
	mk-s390-cdboot.c
	"

build() {
	mkdir -p "$builddir"/libargz
	cp "$srcdir"/argz.h "$builddir"/include/argz.h
	cp "$srcdir"/argz.c "$builddir"/libargz/argz.c
	cp "$srcdir"/Makefile.argz "$builddir"/libargz/Makefile
	make V=1 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" \
		HAVE_GLIB=0 \
		HAVE_GLIB2=0 \
		HAVE_PFM=0 \
		DISTRELEASE="Alpine" \
		LIBEXECINFO_LIBS="-lexecinfo"
	gcc -Wall -o mk-s390-cdboot "$srcdir"/mk-s390-cdboot.c
}

package() {
	make DESTDIR="$pkgdir" DISTRELEASE="Alpine" \
		HAVE_GLIB=0 \
		HAVE_GLIB2=0 \
		HAVE_PFM=0 \
		install
	install -Dm755 mk-s390-cdboot "$pkgdir"/sbin/mk-s390-cdboot
}

sha512sums="
3f37e2c58cc2b7cdb4c7e51b0344e190cd5c6551ee310c6602238e2eeba0a29c6b95a3b20a582e6b4c4654108f9426ebc6b56c8a2f923a2539830b3e5341b5ca  s390-tools-2.21.0.tar.gz
ca1ba0f4c76c1441589138fafbd9f6fc2423cc086301fcb18eb9f47f7884c279cf73cc9e74f4cde305775bd6fa5bf2f9450385ad02b5a20671e59c604823efb5  0002-musl-fixes.patch
6e0f8d999eef08677e9f80d1a07e01556474723b9b00435d463428eee22babe4489257ad5c8fffb650bd0fd5714cdac01dc926e1402f9741fc1327d177ece897  0004-missing-time-header.patch
e41548d83d53e4371afcee3601505520506d05b932aeb91f1ca86e589c010fa5d22777d4617c1e25adfc04fbcf45289cf65a8100108c878323e125e312579220  0006-define-path-mounted.patch
ecfbba213d2a705e2a5a2697090f659670ca1a12e4568c1de87f17d11d72a1a6c524b23b4db25c0558b4e8239c27afddb94d8887d93170b359d77985018f9b9c  0007-tunedasd-no-need-error-h.patch
bdbeb6f3873ede82487c7e4fcac84aa2bf8a922991ec32d029a64cd7142625f5a99920db0f1b6935805d7371ae5a7640c5ea577969937dd96c4f4f996b909ac3  0008-iucvterm-no-nls.patch
c7875cf1cc2de462f481aa0c9bcad14b9bea6aeba18260d5e8686995aefcaa5cbf0e8811046ed25ab70e7c4ada6c7c353debbf3e2cdfefa06c599d8b4b762ee5  0009-link-libexecinfo.patch
f785a899583de8592422e5e46c4e4893196e3c7885e4a0bb4c717c3587db8c1a4c264c80337b1d0c31b39150f3c3b71b876fe156086ace3a542c12678ae7c85e  0010-musl-s390x-signal-def.patch
f5e06e28f77c44f591d74f383ce308a6bfb129b00b291601f2be8866dd1382c597348794be2109c9dc0fa8fdbbee509d036fa6c215e73c4c99f476d3c1cb5a83  0200-dasdinfo-gnu-ext-hack.patch
89ca081aabb5d0f8868ce171cf27265f127585dc57f9950b3ee24d31c1a9a0c25026da77724dc96be8d579768625fee9b2b1214647355dffb49e338dfce18092  0300-disable-program-using-gnu-ext.patch
6d07d0c1f380da42f092038a1434dc1934dead821d6f7c3f8a9e2e85c38e477cf2e34a98d33ac515b67bb0202ca5a469c059d59678c19d9e9bd01456518608e1  0400-busybox-compat.patch
63853e3fbd07b17884509d949fd0386956fc05f17d85ecf70a00a2828b1624b96d41e0957cf5aa000d1fc276408dc50c586c9468d56111d9397db392282bbaec  0500-remove-lib64.patch
3577c2e0715a5553f5061354b3ff9d9ab2e52712b140fb24a84471c3d3e0d47acf74e00d4f05d7a94aa82942cf84f8ae0b30ac15dfe32d10ff2d24a7a7c0c41f  bash.patch
5bc7b2b51bd298d0942ff2f96bb9e30d258100ce87b48285fd4dfeb24448f33a3c679789187d4355c487e64057d7f49a44c0d934bb5f427d18fd625e55de5b0c  argz.patch
c3746ea9e5c638a7adc51bfd8ffebc34f2be45d8d816e9f5711ba8f238fe028f711c91c6732a08a8088e32261f769e2e41a079997295e146082212b8fa84a246  iucvterm-gettext.patch
2e573314d4c4ed90b61da28de22ae8e2f68ced5489f7e5e0b30f51b776efaf40c1f781d3b485418572d8f33a169fa6946b7358cbd4a7de5a3724b20ed622262b  argz.c
50bd5c0f555963dadbfaa72df5bf0801a48743d6d0feddb6ebfa4ffa410196216c1860d3a577361e035169fea4217aef3f04d69394c59db65b60c5ea29eba8cb  argz.h
5e19ccfce59a2a79863db676b0ea4280cb9016cda1a30dc233526f52425c305410dd148453b75c2613acac37e364305ee25f8e545d57c5059cca19a13bac2a5e  Makefile.argz
349eb06895016d16194819c4a04f604720f1373ea61a9bc4c58467281c9a2ed3539bd4e8b6984f4e5177630dbe8b928aa95912c9a3e3b0e1fe275d59f9fe573d  mk-s390-cdboot.c
"
